/*
 * Ventana.java
 *
 
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ventana;

import java.awt.Container;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;

/**
 *
 * @author notebook
 */
public class Ventana extends JFrame implements WindowListener{
    
    private Toolkit tk;
    
    /** Creates a new instance of Ventana */
    public Ventana() {
       ini("<<sin titulo>>", .9);
    }

    public Ventana(String st, double porc) {
       ini(st,porc);
    }
    
    public void add(Container obj){
        this.getContentPane().add(obj);
    }
    
    private void ini(String st, double porc){
       setTitle(st);
       tk= Toolkit.getDefaultToolkit();
       double w= tk.getScreenSize().getWidth();
       double h= tk.getScreenSize().getHeight();
       setSize((int)(w*porc), (int)(h*porc));
       setLocation((int)((w-w*porc)/2), (int)((h-h*porc)/2));
       this.getContentPane().setLayout(null);
       this.addWindowListener(this);
       setVisible(true);
        
    }

    public void windowOpened(WindowEvent e) {
    }

    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }

    public void windowClosed(WindowEvent e) {
        System.exit(0);
   }

    public void windowIconified(WindowEvent e) {
    }

    public void windowDeiconified(WindowEvent e) {
    }

    public void windowActivated(WindowEvent e) {
    }

    public void windowDeactivated(WindowEvent e) {
    }
    
}
